/*
 * Copyright (c) 2019-2020 Arm Limited.
 *
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */
#ifdef __ARM_FEATURE_SVE

#include "arm_gemm.hpp"
#include "../../utils.hpp"

#include <cassert>

namespace arm_gemm {

void sve_gemv_fp32_mla_8VL (
    const float *A_ptr, const float *B_ptr, float *output_ptr,
    size_t N, size_t K,
    const float *bias, Activation act, bool
)
{
    struct KernelArgs {
        float maxval = static_cast<float>(std::numeric_limits<float>::infinity());
        float minval = - static_cast<float>(std::numeric_limits<float>::infinity());
        const float *B_ptr = {};
        size_t output_offset = {};
        unsigned int input_initial_col = {};
    } ka;

    unsigned long flags=0;
    ka.B_ptr = B_ptr;
    switch(act.type) {
        default:
        case Activation::Type::None:
            break;
        case Activation::Type::BoundedReLU:
            ka.maxval = static_cast<float>(act.param1);
            /* fall through */
        case Activation::Type::ReLU:
            ka.minval = 0;
            flags |= 0x2;
            break;
    }
    __asm__ __volatile__(
      "ptrue p2.b\n"
      "cntw x24\n"
      "add x23, %x[N], x24\n"
      "sub x23, x23, #0x1\n"
      "udiv x23, x23, x24\n"
      "mov x22, %x[bias]\n"
      "1:"  // Column loop
      "cmp x23, #0x8\n"
      "bge 50f\n"
      "cmp x23, #0x6\n"
      "bgt 43f\n"
      "beq 36f\n"
      "cmp x23, #0x4\n"
      "bgt 29f\n"
      "beq 22f\n"
      "cmp x23, #0x2\n"
      "bgt 15f\n"
      "beq 8f\n"
      "mov x21, %x[K]\n"
      "mov x20, %x[A_ptr]\n"
      "whilelt p1.s, XZR, %x[N]\n"
      "cbz x22, 2f\n"
      "ld1w { z24.s }, p2/Z, [x22]\n"
      "addvl x22, x22, #1\n"
      "b 3f\n"
      "2:"  // Width 1: no bias
      "mov z24.b, #0x0\n"
      "3:"  // Width 1: setup done
      "cmp x21, #0x4\n"
      "ble 5f\n"
      "4:"  // Width 1: Multiply loop: Main loop head
      "ld1w { z1.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z1.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "add x20, x20, #0x10\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "sub x21, x21, #0x4\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z2.s, z0.s[1]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "cmp x21, #0x4\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z3.s, z0.s[2]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z4.s, z0.s[3]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "prfm pldl1keep, [x20, #0x80]\n"
      "bgt 4b\n"
      "5:"  // Width 1: Multiply loop: Single iteration only
      "ld1w { z5.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z5.s, z0.s[0]\n"
      "add x20, x20, #0x10\n"
      "subs x21, x21, #0x1\n"
      "ble 6f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z6.s, z0.s[1]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "ble 6f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z7.s, z0.s[2]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "ble 6f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z8.s, z0.s[3]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "6:"  // Width 1: Multiply loop: multiply skip
      "prfm pldl1keep, [x20, #0x80]\n"
      "prfm pstl1keep, [%x[output_ptr], #0x0]\n"
      "tbz %x[flags], #1, 7f\n"
      "add x19, %x[args_ptr], %[offset_min]\n"
      "ld1rw { z17.s }, p2/Z, [x19]\n"
      "add x19, %x[args_ptr], %[offset_max]\n"
      "ld1rw { z16.s }, p2/Z, [x19]\n"
      "fmin z24.s, p2/M, z24.s, z16.s\n"
      "fmax z24.s, p2/M, z24.s, z17.s\n"
      "7:"  // Width 1: No activation
      "st1w { z24.s }, p1, [%x[output_ptr]]\n"
      "addvl %x[output_ptr], %x[output_ptr], #1\n"
      "b 57f\n"
      "8:"  // Width 2
      "mov x21, %x[K]\n"
      "mov x20, %x[A_ptr]\n"
      "sub x19, %x[N], x24\n"
      "whilelt p1.s, XZR, x19\n"
      "cbz x22, 9f\n"
      "ld1w { z24.s }, p2/Z, [x22]\n"
      "ld1w { z25.s }, p2/Z, [x22, #1, MUL VL]\n"
      "addvl x22, x22, #2\n"
      "b 10f\n"
      "9:"  // Width 2: no bias
      "mov z24.b, #0x0\n"
      "mov z25.b, #0x0\n"
      "10:"  // Width 2: setup done
      "cmp x21, #0x4\n"
      "ble 12f\n"
      "11:"  // Width 2: Multiply loop: Main loop head
      "ld1w { z1.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z1.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z2.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "sub x21, x21, #0x4\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z3.s, z0.s[1]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z25.s, z4.s, z0.s[1]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "cmp x21, #0x4\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z5.s, z0.s[2]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z25.s, z6.s, z0.s[2]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z7.s, z0.s[3]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z25.s, z8.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "prfm pldl1keep, [x20, #0x80]\n"
      "bgt 11b\n"
      "12:"  // Width 2: Multiply loop: Single iteration only
      "ld1w { z9.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z9.s, z0.s[0]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z10.s, z0.s[0]\n"
      "subs x21, x21, #0x1\n"
      "ble 13f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z11.s, z0.s[1]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z25.s, z12.s, z0.s[1]\n"
      "ble 13f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z13.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z13.s, z0.s[2]\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z25.s, z14.s, z0.s[2]\n"
      "ble 13f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z15.s, z0.s[3]\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z25.s, z16.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "13:"  // Width 2: Multiply loop: multiply skip
      "prfm pldl1keep, [x20, #0x80]\n"
      "prfm pstl1keep, [%x[output_ptr], #0x0]\n"
      "tbz %x[flags], #1, 14f\n"
      "add x19, %x[args_ptr], %[offset_min]\n"
      "ld1rw { z17.s }, p2/Z, [x19]\n"
      "add x19, %x[args_ptr], %[offset_max]\n"
      "ld1rw { z16.s }, p2/Z, [x19]\n"
      "fmin z24.s, p2/M, z24.s, z16.s\n"
      "fmin z25.s, p2/M, z25.s, z16.s\n"
      "fmax z24.s, p2/M, z24.s, z17.s\n"
      "fmax z25.s, p2/M, z25.s, z17.s\n"
      "14:"  // Width 2: No activation
      "st1w { z24.s }, p2, [%x[output_ptr]]\n"
      "st1w { z25.s }, p1, [%x[output_ptr], #1, MUL VL]\n"
      "addvl %x[output_ptr], %x[output_ptr], #2\n"
      "b 57f\n"
      "15:"  // Width 3
      "mov x21, %x[K]\n"
      "mov x20, %x[A_ptr]\n"
      "mov x19, #0x2\n"
      "msub x19, x24, x19, %x[N]\n"
      "whilelt p1.s, XZR, x19\n"
      "cbz x22, 16f\n"
      "ld1w { z24.s }, p2/Z, [x22]\n"
      "ld1w { z25.s }, p2/Z, [x22, #1, MUL VL]\n"
      "ld1w { z26.s }, p2/Z, [x22, #2, MUL VL]\n"
      "addvl x22, x22, #3\n"
      "b 17f\n"
      "16:"  // Width 3: no bias
      "mov z24.b, #0x0\n"
      "mov z25.b, #0x0\n"
      "mov z26.b, #0x0\n"
      "17:"  // Width 3: setup done
      "cmp x21, #0x4\n"
      "ble 19f\n"
      "18:"  // Width 3: Multiply loop: Main loop head
      "ld1w { z1.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "sub x21, x21, #0x4\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z1.s, z0.s[0]\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z2.s, z0.s[0]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z26.s, z3.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "cmp x21, #0x4\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z4.s, z0.s[1]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z5.s, z0.s[1]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z26.s, z6.s, z0.s[1]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z7.s, z0.s[2]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z8.s, z0.s[2]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z26.s, z9.s, z0.s[2]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z10.s, z0.s[3]\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z11.s, z0.s[3]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z26.s, z12.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "prfm pldl1keep, [x20, #0x80]\n"
      "bgt 18b\n"
      "19:"  // Width 3: Multiply loop: Single iteration only
      "ld1w { z13.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "subs x21, x21, #0x1\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z13.s, z0.s[0]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z14.s, z0.s[0]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z26.s, z15.s, z0.s[0]\n"
      "ble 20f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z16.s, z0.s[1]\n"
      "ld1w { z17.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z18.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z17.s, z0.s[1]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z26.s, z18.s, z0.s[1]\n"
      "ble 20f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z19.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z19.s, z0.s[2]\n"
      "ld1w { z20.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z21.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z20.s, z0.s[2]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z26.s, z21.s, z0.s[2]\n"
      "ble 20f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z22.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z22.s, z0.s[3]\n"
      "ld1w { z23.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z1.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z23.s, z0.s[3]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z26.s, z1.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "20:"  // Width 3: Multiply loop: multiply skip
      "prfm pldl1keep, [x20, #0x80]\n"
      "prfm pstl1keep, [%x[output_ptr], #0x0]\n"
      "tbz %x[flags], #1, 21f\n"
      "add x19, %x[args_ptr], %[offset_min]\n"
      "ld1rw { z17.s }, p2/Z, [x19]\n"
      "add x19, %x[args_ptr], %[offset_max]\n"
      "ld1rw { z16.s }, p2/Z, [x19]\n"
      "fmin z24.s, p2/M, z24.s, z16.s\n"
      "fmin z25.s, p2/M, z25.s, z16.s\n"
      "fmin z26.s, p2/M, z26.s, z16.s\n"
      "fmax z24.s, p2/M, z24.s, z17.s\n"
      "fmax z25.s, p2/M, z25.s, z17.s\n"
      "fmax z26.s, p2/M, z26.s, z17.s\n"
      "21:"  // Width 3: No activation
      "st1w { z24.s }, p2, [%x[output_ptr]]\n"
      "st1w { z25.s }, p2, [%x[output_ptr], #1, MUL VL]\n"
      "st1w { z26.s }, p1, [%x[output_ptr], #2, MUL VL]\n"
      "addvl %x[output_ptr], %x[output_ptr], #3\n"
      "b 57f\n"
      "22:"  // Width 4
      "mov x21, %x[K]\n"
      "mov x20, %x[A_ptr]\n"
      "mov x19, #0x3\n"
      "msub x19, x24, x19, %x[N]\n"
      "whilelt p1.s, XZR, x19\n"
      "cbz x22, 23f\n"
      "ld1w { z24.s }, p2/Z, [x22]\n"
      "ld1w { z25.s }, p2/Z, [x22, #1, MUL VL]\n"
      "ld1w { z26.s }, p2/Z, [x22, #2, MUL VL]\n"
      "ld1w { z27.s }, p2/Z, [x22, #3, MUL VL]\n"
      "addvl x22, x22, #4\n"
      "b 24f\n"
      "23:"  // Width 4: no bias
      "mov z24.b, #0x0\n"
      "mov z25.b, #0x0\n"
      "mov z26.b, #0x0\n"
      "mov z27.b, #0x0\n"
      "24:"  // Width 4: setup done
      "cmp x21, #0x4\n"
      "ble 26f\n"
      "25:"  // Width 4: Multiply loop: Main loop head
      "ld1w { z1.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "sub x21, x21, #0x4\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z1.s, z0.s[0]\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z2.s, z0.s[0]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z26.s, z3.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "cmp x21, #0x4\n"
      "fmla z27.s, z4.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z5.s, z0.s[1]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z6.s, z0.s[1]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z26.s, z7.s, z0.s[1]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z27.s, z8.s, z0.s[1]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr]]\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "fmla z24.s, z9.s, z0.s[2]\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z10.s, z0.s[2]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z26.s, z11.s, z0.s[2]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z27.s, z12.s, z0.s[2]\n"
      "ld1w { z13.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z13.s, z0.s[3]\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z14.s, z0.s[3]\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z26.s, z15.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z27.s, z16.s, z0.s[3]\n"
      "prfm pldl1keep, [x20, #0x80]\n"
      "bgt 25b\n"
      "26:"  // Width 4: Multiply loop: Single iteration only
      "ld1w { z17.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z18.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "subs x21, x21, #0x1\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z17.s, z0.s[0]\n"
      "ld1w { z19.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z18.s, z0.s[0]\n"
      "ld1w { z20.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z26.s, z19.s, z0.s[0]\n"
      "fmla z27.s, z20.s, z0.s[0]\n"
      "ble 27f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z21.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z21.s, z0.s[1]\n"
      "ld1w { z22.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z23.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z22.s, z0.s[1]\n"
      "ld1w { z1.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z26.s, z23.s, z0.s[1]\n"
      "fmla z27.s, z1.s, z0.s[1]\n"
      "ble 27f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z2.s, z0.s[2]\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z3.s, z0.s[2]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z26.s, z4.s, z0.s[2]\n"
      "fmla z27.s, z5.s, z0.s[2]\n"
      "ble 27f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z6.s, z0.s[3]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z7.s, z0.s[3]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z26.s, z8.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z27.s, z9.s, z0.s[3]\n"
      "27:"  // Width 4: Multiply loop: multiply skip
      "prfm pldl1keep, [x20, #0x80]\n"
      "prfm pstl1keep, [%x[output_ptr], #0x0]\n"
      "tbz %x[flags], #1, 28f\n"
      "add x19, %x[args_ptr], %[offset_min]\n"
      "ld1rw { z17.s }, p2/Z, [x19]\n"
      "add x19, %x[args_ptr], %[offset_max]\n"
      "ld1rw { z16.s }, p2/Z, [x19]\n"
      "fmin z24.s, p2/M, z24.s, z16.s\n"
      "fmin z25.s, p2/M, z25.s, z16.s\n"
      "fmin z26.s, p2/M, z26.s, z16.s\n"
      "fmin z27.s, p2/M, z27.s, z16.s\n"
      "fmax z24.s, p2/M, z24.s, z17.s\n"
      "fmax z25.s, p2/M, z25.s, z17.s\n"
      "fmax z26.s, p2/M, z26.s, z17.s\n"
      "fmax z27.s, p2/M, z27.s, z17.s\n"
      "28:"  // Width 4: No activation
      "st1w { z24.s }, p2, [%x[output_ptr]]\n"
      "st1w { z25.s }, p2, [%x[output_ptr], #1, MUL VL]\n"
      "st1w { z26.s }, p2, [%x[output_ptr], #2, MUL VL]\n"
      "st1w { z27.s }, p1, [%x[output_ptr], #3, MUL VL]\n"
      "addvl %x[output_ptr], %x[output_ptr], #4\n"
      "b 57f\n"
      "29:"  // Width 5
      "mov x21, %x[K]\n"
      "mov x20, %x[A_ptr]\n"
      "mov x19, #0x4\n"
      "msub x19, x24, x19, %x[N]\n"
      "whilelt p1.s, XZR, x19\n"
      "cbz x22, 30f\n"
      "ld1w { z24.s }, p2/Z, [x22]\n"
      "ld1w { z25.s }, p2/Z, [x22, #1, MUL VL]\n"
      "ld1w { z26.s }, p2/Z, [x22, #2, MUL VL]\n"
      "ld1w { z27.s }, p2/Z, [x22, #3, MUL VL]\n"
      "ld1w { z28.s }, p2/Z, [x22, #4, MUL VL]\n"
      "addvl x22, x22, #5\n"
      "b 31f\n"
      "30:"  // Width 5: no bias
      "mov z24.b, #0x0\n"
      "mov z25.b, #0x0\n"
      "mov z26.b, #0x0\n"
      "mov z27.b, #0x0\n"
      "mov z28.b, #0x0\n"
      "31:"  // Width 5: setup done
      "cmp x21, #0x4\n"
      "ble 33f\n"
      "32:"  // Width 5: Multiply loop: Main loop head
      "ld1w { z1.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "sub x21, x21, #0x4\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z1.s, z0.s[0]\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z2.s, z0.s[0]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "cmp x21, #0x4\n"
      "fmla z26.s, z3.s, z0.s[0]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z27.s, z4.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z28.s, z5.s, z0.s[0]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr]]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "fmla z24.s, z6.s, z0.s[1]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z7.s, z0.s[1]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "fmla z26.s, z8.s, z0.s[1]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z27.s, z9.s, z0.s[1]\n"
      "fmla z28.s, z10.s, z0.s[1]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z11.s, z0.s[2]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z13.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z12.s, z0.s[2]\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z13.s, z0.s[2]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z27.s, z14.s, z0.s[2]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z28.s, z15.s, z0.s[2]\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z16.s, z0.s[3]\n"
      "ld1w { z17.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z18.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z17.s, z0.s[3]\n"
      "ld1w { z19.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z18.s, z0.s[3]\n"
      "ld1w { z20.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z27.s, z19.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z28.s, z20.s, z0.s[3]\n"
      "prfm pldl1keep, [x20, #0x80]\n"
      "bgt 32b\n"
      "33:"  // Width 5: Multiply loop: Single iteration only
      "ld1w { z21.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z22.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "subs x21, x21, #0x1\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z21.s, z0.s[0]\n"
      "ld1w { z23.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z22.s, z0.s[0]\n"
      "ld1w { z1.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "fmla z26.s, z23.s, z0.s[0]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z27.s, z1.s, z0.s[0]\n"
      "fmla z28.s, z2.s, z0.s[0]\n"
      "ble 34f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z3.s, z0.s[1]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z4.s, z0.s[1]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z5.s, z0.s[1]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z27.s, z6.s, z0.s[1]\n"
      "fmla z28.s, z7.s, z0.s[1]\n"
      "ble 34f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z8.s, z0.s[2]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z9.s, z0.s[2]\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z10.s, z0.s[2]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z27.s, z11.s, z0.s[2]\n"
      "fmla z28.s, z12.s, z0.s[2]\n"
      "ble 34f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z13.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z13.s, z0.s[3]\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z14.s, z0.s[3]\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z15.s, z0.s[3]\n"
      "ld1w { z17.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z27.s, z16.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z28.s, z17.s, z0.s[3]\n"
      "34:"  // Width 5: Multiply loop: multiply skip
      "prfm pldl1keep, [x20, #0x80]\n"
      "prfm pstl1keep, [%x[output_ptr], #0x0]\n"
      "tbz %x[flags], #1, 35f\n"
      "add x19, %x[args_ptr], %[offset_min]\n"
      "ld1rw { z17.s }, p2/Z, [x19]\n"
      "add x19, %x[args_ptr], %[offset_max]\n"
      "ld1rw { z16.s }, p2/Z, [x19]\n"
      "fmin z24.s, p2/M, z24.s, z16.s\n"
      "fmin z25.s, p2/M, z25.s, z16.s\n"
      "fmin z26.s, p2/M, z26.s, z16.s\n"
      "fmin z27.s, p2/M, z27.s, z16.s\n"
      "fmin z28.s, p2/M, z28.s, z16.s\n"
      "fmax z24.s, p2/M, z24.s, z17.s\n"
      "fmax z25.s, p2/M, z25.s, z17.s\n"
      "fmax z26.s, p2/M, z26.s, z17.s\n"
      "fmax z27.s, p2/M, z27.s, z17.s\n"
      "fmax z28.s, p2/M, z28.s, z17.s\n"
      "35:"  // Width 5: No activation
      "st1w { z24.s }, p2, [%x[output_ptr]]\n"
      "st1w { z25.s }, p2, [%x[output_ptr], #1, MUL VL]\n"
      "st1w { z26.s }, p2, [%x[output_ptr], #2, MUL VL]\n"
      "st1w { z27.s }, p2, [%x[output_ptr], #3, MUL VL]\n"
      "st1w { z28.s }, p1, [%x[output_ptr], #4, MUL VL]\n"
      "addvl %x[output_ptr], %x[output_ptr], #5\n"
      "b 57f\n"
      "36:"  // Width 6
      "mov x21, %x[K]\n"
      "mov x20, %x[A_ptr]\n"
      "mov x19, #0x5\n"
      "msub x19, x24, x19, %x[N]\n"
      "whilelt p1.s, XZR, x19\n"
      "cbz x22, 37f\n"
      "ld1w { z24.s }, p2/Z, [x22]\n"
      "ld1w { z25.s }, p2/Z, [x22, #1, MUL VL]\n"
      "ld1w { z26.s }, p2/Z, [x22, #2, MUL VL]\n"
      "ld1w { z27.s }, p2/Z, [x22, #3, MUL VL]\n"
      "ld1w { z28.s }, p2/Z, [x22, #4, MUL VL]\n"
      "ld1w { z29.s }, p2/Z, [x22, #5, MUL VL]\n"
      "addvl x22, x22, #6\n"
      "b 38f\n"
      "37:"  // Width 6: no bias
      "mov z24.b, #0x0\n"
      "mov z25.b, #0x0\n"
      "mov z26.b, #0x0\n"
      "mov z27.b, #0x0\n"
      "mov z28.b, #0x0\n"
      "mov z29.b, #0x0\n"
      "38:"  // Width 6: setup done
      "cmp x21, #0x4\n"
      "ble 40f\n"
      "39:"  // Width 6: Multiply loop: Main loop head
      "ld1w { z1.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "sub x21, x21, #0x4\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z1.s, z0.s[0]\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z2.s, z0.s[0]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "cmp x21, #0x4\n"
      "fmla z26.s, z3.s, z0.s[0]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z4.s, z0.s[0]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z28.s, z5.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z29.s, z6.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z7.s, z0.s[1]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z8.s, z0.s[1]\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z9.s, z0.s[1]\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z10.s, z0.s[1]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z28.s, z11.s, z0.s[1]\n"
      "fmla z29.s, z12.s, z0.s[1]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z13.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z13.s, z0.s[2]\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z14.s, z0.s[2]\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z15.s, z0.s[2]\n"
      "ld1w { z17.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z18.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z16.s, z0.s[2]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z28.s, z17.s, z0.s[2]\n"
      "fmla z29.s, z18.s, z0.s[2]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z19.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z19.s, z0.s[3]\n"
      "ld1w { z20.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z21.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z20.s, z0.s[3]\n"
      "ld1w { z22.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z21.s, z0.s[3]\n"
      "ld1w { z23.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z1.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z22.s, z0.s[3]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z28.s, z23.s, z0.s[3]\n"
      "fmla z29.s, z1.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "prfm pldl1keep, [x20, #0x80]\n"
      "bgt 39b\n"
      "40:"  // Width 6: Multiply loop: Single iteration only
      "ld1w { z2.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "subs x21, x21, #0x1\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z2.s, z0.s[0]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z3.s, z0.s[0]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "fmla z26.s, z4.s, z0.s[0]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z27.s, z5.s, z0.s[0]\n"
      "fmla z28.s, z6.s, z0.s[0]\n"
      "fmla z29.s, z7.s, z0.s[0]\n"
      "ble 41f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z8.s, z0.s[1]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z9.s, z0.s[1]\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z10.s, z0.s[1]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z13.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z11.s, z0.s[1]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z28.s, z12.s, z0.s[1]\n"
      "fmla z29.s, z13.s, z0.s[1]\n"
      "ble 41f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z14.s, z0.s[2]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z15.s, z0.s[2]\n"
      "ld1w { z17.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z16.s, z0.s[2]\n"
      "ld1w { z18.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z19.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z17.s, z0.s[2]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z28.s, z18.s, z0.s[2]\n"
      "fmla z29.s, z19.s, z0.s[2]\n"
      "ble 41f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z20.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z20.s, z0.s[3]\n"
      "ld1w { z21.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z22.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z21.s, z0.s[3]\n"
      "ld1w { z23.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z22.s, z0.s[3]\n"
      "ld1w { z1.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z23.s, z0.s[3]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z28.s, z1.s, z0.s[3]\n"
      "fmla z29.s, z2.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "41:"  // Width 6: Multiply loop: multiply skip
      "prfm pldl1keep, [x20, #0x80]\n"
      "prfm pstl1keep, [%x[output_ptr], #0x0]\n"
      "tbz %x[flags], #1, 42f\n"
      "add x19, %x[args_ptr], %[offset_min]\n"
      "ld1rw { z17.s }, p2/Z, [x19]\n"
      "add x19, %x[args_ptr], %[offset_max]\n"
      "ld1rw { z16.s }, p2/Z, [x19]\n"
      "fmin z24.s, p2/M, z24.s, z16.s\n"
      "fmin z25.s, p2/M, z25.s, z16.s\n"
      "fmin z26.s, p2/M, z26.s, z16.s\n"
      "fmin z27.s, p2/M, z27.s, z16.s\n"
      "fmin z28.s, p2/M, z28.s, z16.s\n"
      "fmax z24.s, p2/M, z24.s, z17.s\n"
      "fmax z25.s, p2/M, z25.s, z17.s\n"
      "fmax z26.s, p2/M, z26.s, z17.s\n"
      "fmax z27.s, p2/M, z27.s, z17.s\n"
      "fmax z28.s, p2/M, z28.s, z17.s\n"
      "fmin z29.s, p2/M, z29.s, z16.s\n"
      "fmax z29.s, p2/M, z29.s, z17.s\n"
      "42:"  // Width 6: No activation
      "st1w { z24.s }, p2, [%x[output_ptr]]\n"
      "st1w { z25.s }, p2, [%x[output_ptr], #1, MUL VL]\n"
      "st1w { z26.s }, p2, [%x[output_ptr], #2, MUL VL]\n"
      "st1w { z27.s }, p2, [%x[output_ptr], #3, MUL VL]\n"
      "st1w { z28.s }, p2, [%x[output_ptr], #4, MUL VL]\n"
      "st1w { z29.s }, p1, [%x[output_ptr], #5, MUL VL]\n"
      "addvl %x[output_ptr], %x[output_ptr], #6\n"
      "b 57f\n"
      "43:"  // Width 7
      "mov x21, %x[K]\n"
      "mov x20, %x[A_ptr]\n"
      "mov x19, #0x6\n"
      "msub x19, x24, x19, %x[N]\n"
      "whilelt p1.s, XZR, x19\n"
      "cbz x22, 44f\n"
      "ld1w { z24.s }, p2/Z, [x22]\n"
      "ld1w { z25.s }, p2/Z, [x22, #1, MUL VL]\n"
      "ld1w { z26.s }, p2/Z, [x22, #2, MUL VL]\n"
      "ld1w { z27.s }, p2/Z, [x22, #3, MUL VL]\n"
      "ld1w { z28.s }, p2/Z, [x22, #4, MUL VL]\n"
      "ld1w { z29.s }, p2/Z, [x22, #5, MUL VL]\n"
      "ld1w { z30.s }, p2/Z, [x22, #6, MUL VL]\n"
      "addvl x22, x22, #7\n"
      "b 45f\n"
      "44:"  // Width 7: no bias
      "mov z24.b, #0x0\n"
      "mov z25.b, #0x0\n"
      "mov z26.b, #0x0\n"
      "mov z27.b, #0x0\n"
      "mov z28.b, #0x0\n"
      "mov z29.b, #0x0\n"
      "mov z30.b, #0x0\n"
      "45:"  // Width 7: setup done
      "cmp x21, #0x4\n"
      "ble 47f\n"
      "46:"  // Width 7: Multiply loop: Main loop head
      "ld1w { z1.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "sub x21, x21, #0x4\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z1.s, z0.s[0]\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z2.s, z0.s[0]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "cmp x21, #0x4\n"
      "fmla z26.s, z3.s, z0.s[0]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z4.s, z0.s[0]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "fmla z28.s, z5.s, z0.s[0]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z29.s, z6.s, z0.s[0]\n"
      "fmla z30.s, z7.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z8.s, z0.s[1]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z9.s, z0.s[1]\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z10.s, z0.s[1]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z13.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z11.s, z0.s[1]\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z28.s, z12.s, z0.s[1]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z29.s, z13.s, z0.s[1]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z30.s, z14.s, z0.s[1]\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "fmla z24.s, z15.s, z0.s[2]\n"
      "ld1w { z17.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "ld1w { z18.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z25.s, z16.s, z0.s[2]\n"
      "ld1w { z19.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "fmla z26.s, z17.s, z0.s[2]\n"
      "ld1w { z20.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z18.s, z0.s[2]\n"
      "ld1w { z21.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z28.s, z19.s, z0.s[2]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z29.s, z20.s, z0.s[2]\n"
      "ld1w { z22.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z30.s, z21.s, z0.s[2]\n"
      "ld1w { z23.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "fmla z24.s, z22.s, z0.s[3]\n"
      "ld1w { z1.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z25.s, z23.s, z0.s[3]\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "fmla z26.s, z1.s, z0.s[3]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z2.s, z0.s[3]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z28.s, z3.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z29.s, z4.s, z0.s[3]\n"
      "prfm pldl1keep, [x20, #0x80]\n"
      "fmla z30.s, z5.s, z0.s[3]\n"
      "bgt 46b\n"
      "47:"  // Width 7: Multiply loop: Single iteration only
      "ld1w { z6.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "subs x21, x21, #0x1\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z6.s, z0.s[0]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z7.s, z0.s[0]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "fmla z26.s, z8.s, z0.s[0]\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "fmla z27.s, z9.s, z0.s[0]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z28.s, z10.s, z0.s[0]\n"
      "fmla z29.s, z11.s, z0.s[0]\n"
      "fmla z30.s, z12.s, z0.s[0]\n"
      "ble 48f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z13.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z13.s, z0.s[1]\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z14.s, z0.s[1]\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z15.s, z0.s[1]\n"
      "ld1w { z17.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z18.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z16.s, z0.s[1]\n"
      "ld1w { z19.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z28.s, z17.s, z0.s[1]\n"
      "fmla z29.s, z18.s, z0.s[1]\n"
      "fmla z30.s, z19.s, z0.s[1]\n"
      "ble 48f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z20.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z20.s, z0.s[2]\n"
      "ld1w { z21.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z22.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z21.s, z0.s[2]\n"
      "ld1w { z23.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z22.s, z0.s[2]\n"
      "ld1w { z1.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z23.s, z0.s[2]\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z28.s, z1.s, z0.s[2]\n"
      "fmla z29.s, z2.s, z0.s[2]\n"
      "fmla z30.s, z3.s, z0.s[2]\n"
      "ble 48f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z4.s, z0.s[3]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z5.s, z0.s[3]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z6.s, z0.s[3]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z7.s, z0.s[3]\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z28.s, z8.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z29.s, z9.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z30.s, z10.s, z0.s[3]\n"
      "48:"  // Width 7: Multiply loop: multiply skip
      "prfm pldl1keep, [x20, #0x80]\n"
      "prfm pstl1keep, [%x[output_ptr], #0x0]\n"
      "tbz %x[flags], #1, 49f\n"
      "add x19, %x[args_ptr], %[offset_min]\n"
      "ld1rw { z17.s }, p2/Z, [x19]\n"
      "add x19, %x[args_ptr], %[offset_max]\n"
      "ld1rw { z16.s }, p2/Z, [x19]\n"
      "fmin z24.s, p2/M, z24.s, z16.s\n"
      "fmin z25.s, p2/M, z25.s, z16.s\n"
      "fmin z26.s, p2/M, z26.s, z16.s\n"
      "fmin z27.s, p2/M, z27.s, z16.s\n"
      "fmin z28.s, p2/M, z28.s, z16.s\n"
      "fmax z24.s, p2/M, z24.s, z17.s\n"
      "fmax z25.s, p2/M, z25.s, z17.s\n"
      "fmax z26.s, p2/M, z26.s, z17.s\n"
      "fmax z27.s, p2/M, z27.s, z17.s\n"
      "fmax z28.s, p2/M, z28.s, z17.s\n"
      "fmin z29.s, p2/M, z29.s, z16.s\n"
      "fmin z30.s, p2/M, z30.s, z16.s\n"
      "fmax z29.s, p2/M, z29.s, z17.s\n"
      "fmax z30.s, p2/M, z30.s, z17.s\n"
      "49:"  // Width 7: No activation
      "st1w { z24.s }, p2, [%x[output_ptr]]\n"
      "st1w { z25.s }, p2, [%x[output_ptr], #1, MUL VL]\n"
      "st1w { z26.s }, p2, [%x[output_ptr], #2, MUL VL]\n"
      "st1w { z27.s }, p2, [%x[output_ptr], #3, MUL VL]\n"
      "st1w { z28.s }, p2, [%x[output_ptr], #4, MUL VL]\n"
      "st1w { z29.s }, p2, [%x[output_ptr], #5, MUL VL]\n"
      "st1w { z30.s }, p1, [%x[output_ptr], #6, MUL VL]\n"
      "addvl %x[output_ptr], %x[output_ptr], #7\n"
      "b 57f\n"
      "50:"  // Width 8
      "mov x21, %x[K]\n"
      "mov x20, %x[A_ptr]\n"
      "mov x19, #0x7\n"
      "msub x19, x24, x19, %x[N]\n"
      "whilelt p1.s, XZR, x19\n"
      "cbz x22, 51f\n"
      "ld1w { z24.s }, p2/Z, [x22]\n"
      "ld1w { z25.s }, p2/Z, [x22, #1, MUL VL]\n"
      "ld1w { z26.s }, p2/Z, [x22, #2, MUL VL]\n"
      "ld1w { z27.s }, p2/Z, [x22, #3, MUL VL]\n"
      "ld1w { z28.s }, p2/Z, [x22, #4, MUL VL]\n"
      "ld1w { z29.s }, p2/Z, [x22, #5, MUL VL]\n"
      "ld1w { z30.s }, p2/Z, [x22, #6, MUL VL]\n"
      "ld1w { z31.s }, p2/Z, [x22, #7, MUL VL]\n"
      "addvl x22, x22, #8\n"
      "b 52f\n"
      "51:"  // Width 8: no bias
      "mov z24.b, #0x0\n"
      "mov z25.b, #0x0\n"
      "mov z26.b, #0x0\n"
      "mov z27.b, #0x0\n"
      "mov z28.b, #0x0\n"
      "mov z29.b, #0x0\n"
      "mov z30.b, #0x0\n"
      "mov z31.b, #0x0\n"
      "52:"  // Width 8: setup done
      "cmp x21, #0x4\n"
      "ble 54f\n"
      "53:"  // Width 8: Multiply loop: Main loop head
      "ld1w { z1.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "sub x21, x21, #0x4\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z1.s, z0.s[0]\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z2.s, z0.s[0]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "cmp x21, #0x4\n"
      "fmla z26.s, z3.s, z0.s[0]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z4.s, z0.s[0]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "fmla z28.s, z5.s, z0.s[0]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr], #7, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z29.s, z6.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "fmla z30.s, z7.s, z0.s[0]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z31.s, z8.s, z0.s[0]\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "fmla z24.s, z9.s, z0.s[1]\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z25.s, z10.s, z0.s[1]\n"
      "ld1w { z13.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "fmla z26.s, z11.s, z0.s[1]\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z12.s, z0.s[1]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "fmla z28.s, z13.s, z0.s[1]\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr], #7, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z29.s, z14.s, z0.s[1]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z30.s, z15.s, z0.s[1]\n"
      "ld1w { z17.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z31.s, z16.s, z0.s[1]\n"
      "ld1w { z18.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "fmla z24.s, z17.s, z0.s[2]\n"
      "ld1w { z19.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "ld1w { z20.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z25.s, z18.s, z0.s[2]\n"
      "ld1w { z21.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "fmla z26.s, z19.s, z0.s[2]\n"
      "ld1w { z22.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z20.s, z0.s[2]\n"
      "ld1w { z23.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "fmla z28.s, z21.s, z0.s[2]\n"
      "ld1w { z1.s }, p2/Z, [%x[B_ptr], #7, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z29.s, z22.s, z0.s[2]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z30.s, z23.s, z0.s[2]\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z31.s, z1.s, z0.s[2]\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "fmla z24.s, z2.s, z0.s[3]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z25.s, z3.s, z0.s[3]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "fmla z26.s, z4.s, z0.s[3]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z5.s, z0.s[3]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "fmla z28.s, z6.s, z0.s[3]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr], #7, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z29.s, z7.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z30.s, z8.s, z0.s[3]\n"
      "prfm pldl1keep, [x20, #0x80]\n"
      "fmla z31.s, z9.s, z0.s[3]\n"
      "bgt 53b\n"
      "54:"  // Width 8: Multiply loop: Single iteration only
      "ld1w { z10.s }, p2/Z, [%x[B_ptr]]\n"
      "whilelt p0.s, XZR, x21\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "subs x21, x21, #0x1\n"
      "ld1rqw { z0.s }, p0/Z, [x20]\n"
      "fmla z24.s, z10.s, z0.s[0]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "add x20, x20, #0x10\n"
      "fmla z25.s, z11.s, z0.s[0]\n"
      "ld1w { z13.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "fmla z26.s, z12.s, z0.s[0]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "fmla z27.s, z13.s, z0.s[0]\n"
      "fmla z28.s, z14.s, z0.s[0]\n"
      "ld1w { z17.s }, p2/Z, [%x[B_ptr], #7, MUL VL]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z29.s, z15.s, z0.s[0]\n"
      "fmla z30.s, z16.s, z0.s[0]\n"
      "fmla z31.s, z17.s, z0.s[0]\n"
      "ble 55f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z18.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z18.s, z0.s[1]\n"
      "ld1w { z19.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z20.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z19.s, z0.s[1]\n"
      "ld1w { z21.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z20.s, z0.s[1]\n"
      "ld1w { z22.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z23.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z21.s, z0.s[1]\n"
      "ld1w { z1.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "ld1w { z2.s }, p2/Z, [%x[B_ptr], #7, MUL VL]\n"
      "fmla z28.s, z22.s, z0.s[1]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z29.s, z23.s, z0.s[1]\n"
      "fmla z30.s, z1.s, z0.s[1]\n"
      "fmla z31.s, z2.s, z0.s[1]\n"
      "ble 55f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "subs x21, x21, #0x1\n"
      "ld1w { z3.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z3.s, z0.s[2]\n"
      "ld1w { z4.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z5.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z4.s, z0.s[2]\n"
      "ld1w { z6.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z5.s, z0.s[2]\n"
      "ld1w { z7.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z8.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z6.s, z0.s[2]\n"
      "ld1w { z9.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "ld1w { z10.s }, p2/Z, [%x[B_ptr], #7, MUL VL]\n"
      "fmla z28.s, z7.s, z0.s[2]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z29.s, z8.s, z0.s[2]\n"
      "fmla z30.s, z9.s, z0.s[2]\n"
      "fmla z31.s, z10.s, z0.s[2]\n"
      "ble 55f\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "ld1w { z11.s }, p2/Z, [%x[B_ptr]]\n"
      "fmla z24.s, z11.s, z0.s[3]\n"
      "ld1w { z12.s }, p2/Z, [%x[B_ptr], #1, MUL VL]\n"
      "ld1w { z13.s }, p2/Z, [%x[B_ptr], #2, MUL VL]\n"
      "fmla z25.s, z12.s, z0.s[3]\n"
      "ld1w { z14.s }, p2/Z, [%x[B_ptr], #3, MUL VL]\n"
      "fmla z26.s, z13.s, z0.s[3]\n"
      "ld1w { z15.s }, p2/Z, [%x[B_ptr], #4, MUL VL]\n"
      "ld1w { z16.s }, p2/Z, [%x[B_ptr], #5, MUL VL]\n"
      "fmla z27.s, z14.s, z0.s[3]\n"
      "ld1w { z17.s }, p2/Z, [%x[B_ptr], #6, MUL VL]\n"
      "ld1w { z18.s }, p2/Z, [%x[B_ptr], #7, MUL VL]\n"
      "fmla z28.s, z15.s, z0.s[3]\n"
      "addvl %x[B_ptr], %x[B_ptr], #8\n"
      "fmla z29.s, z16.s, z0.s[3]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x400]\n"
      "prfm pldl1keep, [%x[B_ptr], #0x440]\n"
      "fmla z30.s, z17.s, z0.s[3]\n"
      "fmla z31.s, z18.s, z0.s[3]\n"
      "55:"  // Width 8: Multiply loop: multiply skip
      "prfm pldl1keep, [x20, #0x80]\n"
      "prfm pstl1keep, [%x[output_ptr], #0x0]\n"
      "tbz %x[flags], #1, 56f\n"
      "add x19, %x[args_ptr], %[offset_min]\n"
      "ld1rw { z17.s }, p2/Z, [x19]\n"
      "add x19, %x[args_ptr], %[offset_max]\n"
      "ld1rw { z16.s }, p2/Z, [x19]\n"
      "fmin z24.s, p2/M, z24.s, z16.s\n"
      "fmin z25.s, p2/M, z25.s, z16.s\n"
      "fmin z26.s, p2/M, z26.s, z16.s\n"
      "fmin z27.s, p2/M, z27.s, z16.s\n"
      "fmin z28.s, p2/M, z28.s, z16.s\n"
      "fmax z24.s, p2/M, z24.s, z17.s\n"
      "fmax z25.s, p2/M, z25.s, z17.s\n"
      "fmax z26.s, p2/M, z26.s, z17.s\n"
      "fmax z27.s, p2/M, z27.s, z17.s\n"
      "fmax z28.s, p2/M, z28.s, z17.s\n"
      "fmin z29.s, p2/M, z29.s, z16.s\n"
      "fmin z30.s, p2/M, z30.s, z16.s\n"
      "fmin z31.s, p2/M, z31.s, z16.s\n"
      "fmax z29.s, p2/M, z29.s, z17.s\n"
      "fmax z30.s, p2/M, z30.s, z17.s\n"
      "fmax z31.s, p2/M, z31.s, z17.s\n"
      "56:"  // Width 8: No activation
      "st1w { z24.s }, p2, [%x[output_ptr]]\n"
      "subs x23, x23, #0x8\n"
      "st1w { z25.s }, p2, [%x[output_ptr], #1, MUL VL]\n"
      "sub %x[N], %x[N], x24, LSL #3\n"
      "st1w { z26.s }, p2, [%x[output_ptr], #2, MUL VL]\n"
      "st1w { z27.s }, p2, [%x[output_ptr], #3, MUL VL]\n"
      "st1w { z28.s }, p2, [%x[output_ptr], #4, MUL VL]\n"
      "st1w { z29.s }, p2, [%x[output_ptr], #5, MUL VL]\n"
      "st1w { z30.s }, p2, [%x[output_ptr], #6, MUL VL]\n"
      "st1w { z31.s }, p1, [%x[output_ptr], #7, MUL VL]\n"
      "addvl %x[output_ptr], %x[output_ptr], #8\n"
      "bgt 1b\n"
      "57:"  // Exit

      : [B_ptr] "+r" (B_ptr), [N] "+r" (N), [output_ptr] "+r" (output_ptr)
      : [A_ptr] "r" (A_ptr), [K] "r" (K), [args_ptr] "r" (&ka), [bias] "r" (bias), [flags] "r" (flags), [offset_max] "I" (offsetof(KernelArgs, maxval)), [offset_min] "I" (offsetof(KernelArgs, minval))
      : "cc", "memory", "p0", "p1", "p2", "x19", "x20", "x21", "x22", "x23", "x24", "z0", "z1", "z2", "z3", "z4", "z5", "z6", "z7", "z8", "z9", "z10", "z11", "z12", "z13", "z14", "z15", "z16", "z17", "z18", "z19", "z20", "z21", "z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31"
    );
}

} // namespace arm_gemm

#endif
